package peer.p2pnet.message;

import java.net.DatagramPacket;

import peer.Message;
import peer.tools.ByteShortSwitch;

public class PingMessage2 extends Message{
	public short sType=peer.tools.MessageType.sType_PingMessage2;
	byte[] dpData=new byte[8];
	int pingSessionId;
	public PingMessage2(int pingSessionId){
		this.pingSessionId=pingSessionId;
		ByteShortSwitch.toByteArray(ver, dpData, 0);  //add: ver
		ByteShortSwitch.toByteArray(sType, dpData, 2);  //add: service type
		peer.tools.ByteIntSwitch.toByteArray(pingSessionId, dpData, 4);
		dp=new DatagramPacket(dpData,dpData.length);
	}
	
	public PingMessage2(DatagramPacket dp){
		this.dp=dp;
		dpData=dp.getData();
		ver=ByteShortSwitch.toShort(dpData, 0);
		sType=ByteShortSwitch.toShort(dpData, 2);
		pingSessionId=peer.tools.ByteIntSwitch.toInt(dpData, 4);
	}
	
	public int getPingSessionId(){
		return pingSessionId;
	}
	
}
